<%-- 
    Document   : registerUser
    Created on : Jul 14, 2011, 5:31:57 PM
    Author     : northpole
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <jsp:useBean id="userInfo" scope="page" class="user.User" />
        <%userInfo.setAll(request.getParameter("name"), request.getParameter("surname"),request.getParameter("interests")
                , request.getParameter("dateOfBirth"), request.getParameter("welcomeText"));
        userInfo.setUsername(request.getParameter("username"));
        userInfo.setPassword(request.getParameter("password"));

        String x="koko";
        if(userInfo!=null)
        x=userInfo.Register();
        if(x ==null)
            {out.write("X is Null!!!");}
        String redirectURL ="register.jsp?name="+request.getParameter("name")
                +"&surname="+request.getParameter("surname")
                +"&interests="+request.getParameter("interests")
                +"&dateOfBirth="+request.getParameter("dateOfBirth")
                +"&welcomeText="+request.getParameter("welcomeText")
                +"&password="+request.getParameter("password");
        String newUrl=null;
        if(x!=null && x.equals("NeedMoarInfo"))
        {newUrl=redirectURL+"&message=Please-Fill-All-of-The-Boxes";}
        else if(x!=null && x.equals("Username Exists")){
        newUrl=redirectURL+"&message=Username Exists";
        }
        else if(x!=null && x.equals("OK"))
        {newUrl="index.jsp";}
        else
            out.write("<h1>"+x+"</h1>");
        
     //  out.write(newUrl);
     //  out.write("</br>"+x+"</br>");
     //  out.write(redirectURL);
    //   out.write("</br>"+request.getParameter("username"));
         response.sendRedirect(newUrl);
   %>
    </head>
    <body>
        
    </body>
</html>
